//
//  PayTypeModel.m
//  quickBatchManager
//
//  Created by jack on 15/10/15.
//  Copyright © 2015年 jack. All rights reserved.
//

#import "PayTypeModel.h"
#import "UploadData.h"
@implementation PayTypeModel
+(NSString *)getTableName
{
    return @"qbm_pay_type";
}


+(NSString *)getPrimaryKey
{
    return @"t_id";
}



+(void)dbDidInserted:(NSObject*)entity result:(BOOL)result
{
    if([entity isKindOfClass:[PayTypeModel class]])
    {
        PayTypeModel *model = (PayTypeModel *)entity;
        UploadData *data = [[UploadData alloc] init];
        data.t_table = [PayTypeModel getTableName];
        data.t_opType = DB_INSERT;
        data.t_pkName = [self getPrimaryKey];
        data.t_pk = model.rowid;
        data.t_time = [[NSDate date] timeIntervalSince1970InMilliSecond];
        model.t_id = data.t_pk;
        NSString *value = [self DataTOjsonString:model.keyValues];
        data.content = value;
        [UploadData insertToDB:data];
       //  NSLog(@"DB PayTypeModel content %@",data.content);
    }
   
    
   
}

+(void)dbDidUpdated:(NSObject*)entity result:(BOOL)result
{
    if([entity isKindOfClass:[PayTypeModel class]])
    {
        PayTypeModel *model = (PayTypeModel *)entity;
        UploadData *data = [[UploadData alloc] init];
        data.t_table = [PayTypeModel getTableName];
        data.t_opType = DB_UPDATE;
        data.t_pkName = [self getPrimaryKey];
        data.t_pk = model.rowid;
        data.t_time = [[NSDate date] timeIntervalSince1970InMilliSecond];
        model.t_id = data.t_pk;
        NSString *value = [self DataTOjsonString:model.keyValues];
        data.content = value;

        [UploadData insertToDB:data];
    }
  //  NSLog(@"DB 更新数据");
}


+(void)dbDidDeleted:(NSObject*)entity result:(BOOL)result
{
    if([entity isKindOfClass:[PayTypeModel class]])
    {
        PayTypeModel *model = (PayTypeModel *)entity;
        UploadData *data = [[UploadData alloc] init];
        data.t_table = [PayTypeModel getTableName];
        data.t_opType = DB_DELETE;
        data.t_pkName = [self getPrimaryKey];
        data.t_pk = model.rowid;
        model.t_id = data.t_pk;
        NSString *value = [self DataTOjsonString:model.keyValues];
        data.content = value;
        data.t_time = [[NSDate date] timeIntervalSince1970InMilliSecond];
        [UploadData insertToDB:data];
        NSLog(@"DB 删除数据成功:%@",model.payTypeName);
    }
   //  NSLog(@"DB 删除数据");
}
@end
